﻿' This is generated Code:
' Class Created by Script @ createclass.aspx
' (c) 2009-2011 Secura Hosting Ltd.  All Rights Reserved.
'
'   ClientDetailsCollection.vb
'
'   part of WHMCSdotnet (http://whmcsdotnet.wordpress.com)
'
'   Copyright (C) 2009-2011 Mark Castle <markcastle@gmail.com>
'   All rights reserved. 
'   Copyright (C) 2009-2011 Secura Hosting Ltd <code@securahosting.com>.
'   All rights reserved.
' 
'   Redistribution and use in source and binary forms, with or without modification,
'   are permitted provided that the following conditions are met:
' 
'   - Redistributions of source code must  retain  the  above copyright notice, this
'     list of conditions and the following disclaimer.
' 
'   - Redistributions in binary form  must  reproduce the  above  copyright  notice,
'     this list of conditions  and  the  following  disclaimer in  the documentation
'     and/or other materials provided with the distribution.
' 
'   - Neither  the  name  of  Secura Hosting Ltd, Mark Castle  nor the names of  its
'     contributors may be used to endorse or  promote  products  derived  from  this
'     software without specific prior written permission.
' 
'   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
'   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,  BUT  NOT  LIMITED TO, THE IMPLIED
'   WARRANTIES  OF  MERCHANTABILITY   AND  FITNESS  FOR  A  PARTICULAR  PURPOSE  ARE
'   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
'   ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL DAMAGES
'   (INCLUDING, BUT NOT LIMITED TO,  PROCUREMENT  OF  SUBSTITUTE  GOODS OR SERVICES;
'   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  HOWEVER  CAUSED AND ON
'   ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT  LIABILITY,  OR TORT
'   (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING  IN  ANY WAY OUT OF THE USE OF THIS
'   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Option Explicit On
Option Strict On

Imports System
Imports System.Reflection
Imports System.Collections
Imports System.Diagnostics


Namespace Secura.WHMCS.Data

    Public Class ClientDetails


        Private Const MODULE_NAME As String = "Secura.WHMCS.Data.ClientDetails"

#Region "Properties"

        Private _xDoc As XDocument

        Private _Id As Integer = 0
        Private _UserId As Integer = 0
        Private _FirstName As String = ""
        Private _LastName As String = ""
        Private _CompanyName As String = ""
        Private _Email As String = ""
        Private _Address1 As String = ""
        Private _Address2 As String = ""
        Private _City As String = ""
        Private _State As String = ""
        Private _Postcode As String = ""
        Private _Country As String = ""
        Private _CountryName As String = ""
        Private _PhoneNumber As String = ""
        Private _Notes As String = ""
        Private _Password As String = ""
        Private _Currency As Integer = 0
        Private _SecurityQID As Integer = 0
        Private _SecurityQans As String = ""
        Private _GroupId As Integer = 0
        Private _Status As Secura.WHMCS.API.StatusTypes
        Private _Credit As Decimal = 0
        Private _TaxExempt As String = ""
        Private _LateFeeOveride As String = ""
        Private _OverideDueNotices As String = ""
        Private _Language As String = ""
        Private _LastLogin As String = ""
        Private _BillingCid As Integer = 0
        Private _Currency_Code As String = ""
        Private _CCType As String = ""
        Private _CCLastFour As String = ""
        Private _SeparateInvoices As String = ""
        Private _DisableAutoCC As String = ""


        ' -----------------------------------------------
        ' -- Properties
        ' -----------------------------------------------

        ''' <summary>
        ''' Id Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Id() As Integer
            Get
                Return _Id
            End Get

            Set(ByVal Value As Integer)
                _Id = Value
            End Set
        End Property

        ''' <summary>
        ''' UserId Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property UserId() As Integer
            Get
                Return _UserId
            End Get

            Set(ByVal Value As Integer)
                _UserId = Value
            End Set
        End Property

        ''' <summary>
        ''' FirstName Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FirstName() As String
            Get
                Return _FirstName
            End Get

            Set(ByVal Value As String)
                _FirstName = Value
            End Set
        End Property

        ''' <summary>
        ''' LastName Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property LastName() As String
            Get
                Return _LastName
            End Get

            Set(ByVal Value As String)
                _LastName = Value
            End Set
        End Property

        ''' <summary>
        ''' CompanyName Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CompanyName() As String
            Get
                Return _CompanyName
            End Get

            Set(ByVal Value As String)
                _CompanyName = Value
            End Set
        End Property

        ''' <summary>
        ''' Email Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Email() As String
            Get
                Return _Email
            End Get

            Set(ByVal Value As String)
                _Email = Value
            End Set
        End Property

        ''' <summary>
        ''' Address1 Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Address1() As String
            Get
                Return _Address1
            End Get

            Set(ByVal Value As String)
                _Address1 = Value
            End Set
        End Property

        ''' <summary>
        ''' Address2 Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Address2() As String
            Get
                Return _Address2
            End Get

            Set(ByVal Value As String)
                _Address2 = Value
            End Set
        End Property

        ''' <summary>
        ''' City Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property City() As String
            Get
                Return _City
            End Get

            Set(ByVal Value As String)
                _City = Value
            End Set
        End Property

        ''' <summary>
        ''' State Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property State() As String
            Get
                Return _State
            End Get

            Set(ByVal Value As String)
                _State = Value
            End Set
        End Property

        ''' <summary>
        ''' Postcode Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Postcode() As String
            Get
                Return _Postcode
            End Get

            Set(ByVal Value As String)
                _Postcode = Value
            End Set
        End Property

        ''' <summary>
        ''' Country Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Country() As String
            Get
                Return _Country
            End Get

            Set(ByVal Value As String)
                _Country = Value
            End Set
        End Property

        ''' <summary>
        ''' CountryName Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CountryName() As String
            Get
                Return _CountryName
            End Get

            Set(ByVal Value As String)
                _CountryName = Value
            End Set
        End Property

        ''' <summary>
        ''' PhoneNumber Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PhoneNumber() As String
            Get
                Return _PhoneNumber
            End Get

            Set(ByVal Value As String)
                _PhoneNumber = Value
            End Set
        End Property

        ''' <summary>
        ''' Notes Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Notes() As String
            Get
                Return _Notes
            End Get

            Set(ByVal Value As String)
                _Notes = Value
            End Set
        End Property

        ''' <summary>
        ''' Password Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Password() As String
            Get
                Return _Password
            End Get

            Set(ByVal Value As String)
                _Password = Value
            End Set
        End Property

        ''' <summary>
        ''' Currency Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Currency() As Integer
            Get
                Return _Currency
            End Get

            Set(ByVal Value As Integer)
                _Currency = Value
            End Set
        End Property

        ''' <summary>
        ''' SecurityQID Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecurityQID() As Integer
            Get
                Return _SecurityQID
            End Get

            Set(ByVal Value As Integer)
                _SecurityQID = Value
            End Set
        End Property

        ''' <summary>
        ''' SecurityQans Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecurityQans() As String
            Get
                Return _SecurityQans
            End Get

            Set(ByVal Value As String)
                _SecurityQans = Value
            End Set
        End Property

        ''' <summary>
        ''' GroupId Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property GroupId() As Integer
            Get
                Return _GroupId
            End Get

            Set(ByVal Value As Integer)
                _GroupId = Value
            End Set
        End Property

        ''' <summary>
        ''' Status Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Status() As Secura.WHMCS.API.StatusTypes
            Get
                Return _Status
            End Get

            Set(ByVal Value As Secura.WHMCS.API.StatusTypes)
                _Status = Value
            End Set
        End Property

        ''' <summary>
        ''' Credit Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Credit() As Decimal
            Get
                Return _Credit
            End Get

            Set(ByVal Value As Decimal)
                _Credit = Value
            End Set
        End Property

        ''' <summary>
        ''' TaxExempt Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property TaxExempt() As String
            Get
                Return _TaxExempt
            End Get

            Set(ByVal Value As String)
                _TaxExempt = Value
            End Set
        End Property

        ''' <summary>
        ''' LateFeeOveride Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property LateFeeOveride() As String
            Get
                Return _LateFeeOveride
            End Get

            Set(ByVal Value As String)
                _LateFeeOveride = Value
            End Set
        End Property

        ''' <summary>
        ''' OverideDueNotices Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property OverideDueNotices() As String
            Get
                Return _OverideDueNotices
            End Get

            Set(ByVal Value As String)
                _OverideDueNotices = Value
            End Set
        End Property

        ''' <summary>
        ''' Language Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Language() As String
            Get
                Return _Language
            End Get

            Set(ByVal Value As String)
                _Language = Value
            End Set
        End Property

        ''' <summary>
        ''' LastLogin Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property LastLogin() As String
            Get
                Return _LastLogin
            End Get

            Set(ByVal Value As String)
                _LastLogin = Value
            End Set
        End Property

        ''' <summary>
        ''' BillingCid Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property BillingCid() As Integer
            Get
                Return _BillingCid
            End Get

            Set(ByVal Value As Integer)
                _BillingCid = Value
            End Set
        End Property

        ''' <summary>
        ''' Currency_Code Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Currency_Code() As String
            Get
                Return _Currency_Code
            End Get

            Set(ByVal Value As String)
                _Currency_Code = Value
            End Set
        End Property

        ''' <summary>
        ''' CCType Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CCType() As String
            Get
                Return _CCType
            End Get

            Set(ByVal Value As String)
                _CCType = Value
            End Set
        End Property

        ''' <summary>
        ''' CCLastFour Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CCLastFour() As String
            Get
                Return _CCLastFour
            End Get

            Set(ByVal Value As String)
                _CCLastFour = Value
            End Set
        End Property

        ''' <summary>
        ''' SeparateInvoices Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SeparateInvoices() As String
            Get
                Return _SeparateInvoices
            End Get

            Set(ByVal Value As String)
                _SeparateInvoices = Value
            End Set
        End Property

        ''' <summary>
        ''' DisableAutoCC Property (r/w)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property DisableAutoCC() As String
            Get
                Return _DisableAutoCC
            End Get

            Set(ByVal Value As String)
                _DisableAutoCC = Value
            End Set
        End Property



#End Region

#Region "Public Methods"

        ' -----------------------------------------------
        ' -- Public Methods
        ' -----------------------------------------------



#End Region

#Region "Constructors"

        ' -----------------------------------------------
        ' -- Constructor
        ' -----------------------------------------------	

        ''' <summary>
        ''' New Constructor
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
        End Sub

        Public Sub New(ByVal Id As Integer, ByVal UserId As Integer, ByVal FirstName As String, ByVal LastName As String, ByVal CompanyName As String, ByVal Email As String, ByVal Address1 As String, ByVal Address2 As String, ByVal City As String, ByVal State As String, ByVal Postcode As String, ByVal Country As String, ByVal CountryName As String, ByVal PhoneNumber As String, ByVal Notes As String, ByVal Password As String, ByVal Currency As Integer, ByVal SecurityQID As Integer, ByVal SecurityQans As String, ByVal GroupId As Integer, ByVal Status As Secura.WHMCS.API.StatusTypes, ByVal Credit As Decimal, ByVal TaxExempt As String, ByVal LateFeeOveride As String, ByVal OverideDueNotices As String, ByVal Language As String, ByVal LastLogin As String, ByVal BillingCid As Integer, ByVal Currency_Code As String, ByVal CCType As String, ByVal CCLastFour As String, ByVal SeparateInvoices As String, ByVal DisableAutoCC As String)
            _Id = Id
            _UserId = UserId
            _FirstName = FirstName
            _LastName = LastName
            _CompanyName = CompanyName
            _Email = Email
            _Address1 = Address1
            _Address2 = Address2
            _City = City
            _State = State
            _Postcode = Postcode
            _Country = Country
            _CountryName = CountryName
            _PhoneNumber = PhoneNumber
            _Notes = Notes
            _Password = Password
            _Currency = Currency
            _SecurityQID = SecurityQID
            _SecurityQans = SecurityQans
            _GroupId = GroupId
            _Status = Status
            _Credit = Credit
            _TaxExempt = TaxExempt
            _LateFeeOveride = LateFeeOveride
            _OverideDueNotices = OverideDueNotices
            _Language = Language
            _LastLogin = LastLogin
            _BillingCid = BillingCid
            _Currency_Code = Currency_Code
            _CCType = CCType
            _CCLastFour = CCLastFour
            _SeparateInvoices = SeparateInvoices
            _DisableAutoCC = DisableAutoCC
        End Sub



        Sub New(ByVal XDoc As XDocument)
            ' TODO: Complete member initialization 
            _xDoc = XDoc
            If _xDoc.<whmcsapi>.<client>(0).Elements().Count() < 1 Then
                Exit Sub
            End If

            For Each Result In _xDoc.<whmcsapi>.<client>

                Me.Id = CInt(Result...<id>.Value().ToString())
                Me.UserId = CInt(Result...<userid>.Value().ToString())
                Me.FirstName = Result...<firstname>.Value.ToString()
                Me.LastName = Result...<lastname>.Value.ToString()
                Me.CompanyName = Result...<companyname>.Value.ToString()
                Me.Email = Result...<email>.Value.ToString()
                Me.Address1 = Result...<address1>.Value.ToString()
                Me.Address2 = Result...<address2>.Value.ToString()
                Me.City = Result...<city>.Value.ToString()
                Me.State = Result...<state>.Value.ToString()
                Me.Postcode = Result...<postcode>.Value.ToString()
                Me.Country = Result...<country>.Value.ToString()
                Me.CountryName = Result...<countryname>.Value.ToString()
                Me.PhoneNumber = Result...<phonenumber>.Value.ToString()
                Me.Notes = Result...<notes>.Value.ToString()
                Me.Password = Result...<password>.Value.ToString()
                Me.Currency = CInt(Result...<currency>.Value().ToString())
                Me.SecurityQID = CInt(Result...<securityqid>.Value.ToString())
                Me.SecurityQans = Result...<securityqans>.Value.ToString()
                Me.GroupId = CInt(Result...<groupid>.Value.ToString())
                Me.Status = CType(System.Enum.Parse(GetType(Secura.WHMCS.API.StatusTypes), Result...<status>.Value.ToString()), Secura.WHMCS.API.StatusTypes)
                Me.Credit = Convert.ToDecimal(Result...<credit>.Value.ToString())
                Me.TaxExempt = Result...<taxexempt>.Value.ToString()
                Me.LateFeeOveride = Result...<latefeeoveride>.Value.ToString()
                Me.OverideDueNotices = Result...<overideduenotices>.Value.ToString()
                Me.Language = Result...<language>.Value.ToString()
                Me.LastLogin = Result...<lastlogin>.Value.ToString()
                Me.BillingCid = CInt(Result...<billingcid>.Value.ToString())
                Me.Currency_Code = Result...<currency_code>.Value.ToString()
                Me.CCType = Result...<cctype>.Value.ToString()
                Me.CCLastFour = Result...<cclastfour>.Value.ToString()
                Me.SeparateInvoices = Result...<separateinvoices>.Value.ToString()
                Me.DisableAutoCC = Result...<disableautocc>.Value.ToString()

            Next

        End Sub

#End Region

#Region "Private Methods"

        ' -----------------------------------------------
        ' -- Private Methods
        ' -----------------------------------------------
        ' Your Private Methods Go Here.

#End Region

#Region "Supporting Objects"

        ''' <summary>
        ''' Some Utilities used by these classes
        ''' </summary>
        ''' <remarks></remarks>
        Public Class Utilities

            ''' <summary>
            ''' CheckNull Method
            ''' If Item is Nothing then Returns Nothing rather than DbNull
            ''' </summary>
            ''' <param name="Item"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function CheckNull(ByVal Item As Object) As Object
                If Item Is System.DBNull.Value Then
                    Return Nothing
                Else
                    Return Item
                End If
            End Function

            ''' <summary>
            ''' CStrEx Method
            ''' A CStr function that doesn't cause an exception when a DBNull is encountered
            ''' </summary>
            ''' <param name="test"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function CStrEx(ByVal test As Object) As String
                If IsDBNull(test) Then
                    Return ("")
                Else
                    Return CStr(test)
                End If
            End Function

            ''' <summary>
            ''' CBoolEx Method
            ''' A CBool function that doesn't cause an exception when a DBNull is encountered
            ''' </summary>
            ''' <param name="test"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function CBoolEx(ByVal test As Object) As Boolean
                If IsDBNull(test) Then
                    Return False
                Else
                    Return CBool(test)
                End If
            End Function

            ''' <summary>
            ''' CIntEx Method
            ''' A CInt function that doesn't cause an exception when a DBNull is encountered
            ''' </summary>
            ''' <param name="test"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function CIntEx(ByVal test As Object) As Integer
                If IsDBNull(test) Then
                    Return 0
                Else
                    Return CInt(test)
                End If
            End Function

        End Class


        ''' <summary>
        ''' A Local debugging object
        ''' </summary>
        ''' <remarks></remarks>
        Class Debug

            Public Enum LogLevel As Integer
                NoLogging = 0
                Normal = 1
                Verbose = 2
                Debug = 3
            End Enum

            ''' <summary>
            ''' A Simple Logging Method
            ''' </summary>
            ''' <param name="Text"></param>
            ''' <param name="Logtype"></param>
            ''' <param name="Level"></param>
            ''' <param name="Success"></param>
            ''' <param name="WriteToEventLog"></param>
            ''' <param name="Filename"></param>
            ''' <param name="WriteToConsole"></param>
            ''' <param name="IncludePrefix"></param>
            ''' <param name="IncludeTime"></param>
            ''' <remarks></remarks>
            Public Shared Sub Log(ByVal Text As String, _
                                      Optional ByVal Logtype As EventLogEntryType = EventLogEntryType.Information, _
                                      Optional ByVal Level As LogLevel = LogLevel.Normal, _
                                      Optional ByVal Success As Boolean = True, _
                                      Optional ByVal WriteToEventLog As Boolean = True, _
                                      Optional ByVal Filename As String = "", _
                                      Optional ByVal WriteToConsole As Boolean = False, _
                                      Optional ByVal IncludePrefix As Boolean = True, _
                                      Optional ByVal IncludeTime As Boolean = True)

                ' Secura.Debug.Log(Text, Logtype, CType(Level, Secura.ClientDetails.Debug.LogLevel), Success, WriteToEventLog, Filename, WriteToConsole, IncludePrefix, IncludeTime)
                Trace.Write(LogType.ToString() & ": " & Text, "Secura.WHMCS.Data.ClientDetails")

            End Sub

        End Class
#End Region

    End Class

#Region "Collection"

    Public Class ClientDetailsCollection
        Inherits Secura.WHMCS.Data.CollectionHelpers.ClientDetailsBase.SortableCollectionBase

        Public Sub New()
            MyBase.SortObjectType = GetType(ClientDetails)
        End Sub

        ' ------------------------------------------------------------------------
        ' -- Property: Count
        ' -- Gets the number of elements contained in the Collection instance.
        ' -- This property is inherited from CollectionBase and available by default.
        ' ------------------------------------------------------------------------	

        ' ------------------------------------------------------------------------
        ' -- Property: Item
        ' -- Gets or sets the element at the specified index.
        ' ------------------------------------------------------------------------
        Default Public Property Item(ByVal Index As Integer) As ClientDetails
            Get
                Return CType(MyBase.List.Item(Index), ClientDetails)
            End Get
            Set(ByVal Value As ClientDetails)
                MyBase.List.Item(Index) = Value
            End Set
        End Property

        ' ------------------------------------------------------------------------
        ' -- Method: Clear
        ' -- Removes all objects from the CollectionBase instance
        ' -- This Method is inherited from CollectionBase and is available by default.
        ' ------------------------------------------------------------------------	
        'Public Function Clear() As Integer
        '	MyBase.List.Clear
        'End Function


        ' ------------------------------------------------------------------------
        ' -- Method: Add
        ' -- Searches Adds an object to the end of the Collection. 
        ' ------------------------------------------------------------------------	
        Public Function Add(ByVal Item As ClientDetails) As Integer
            Return MyBase.List.Add(Item)
        End Function

        ' ------------------------------------------------------------------------
        ' -- Method: IndexOf
        ' -- Searches for the specified Object and returns the zero-based index of 
        ' -- the first occurrence within the entire Collection.
        ' ------------------------------------------------------------------------
        Public Function IndexOf(ByVal Item As ClientDetails) As Integer
            Return MyBase.List.IndexOf(Item)
        End Function 'IndexOf

        ' ------------------------------------------------------------------------
        ' -- Method: Insert
        ' -- Inserts an element into the CollectionBase at the specified index. 
        ' ------------------------------------------------------------------------	
        Public Sub Insert(ByVal Index As Integer, ByVal Item As ClientDetails)
            MyBase.List.Insert(Index, Item)
        End Sub 'Insert

        ' ------------------------------------------------------------------------
        ' -- Method: Remove
        ' -- Removes the first occurrence of a specific object from the Collection. 
        ' ------------------------------------------------------------------------	
        Public Sub Remove(ByVal Item As ClientDetails)
            MyBase.List.Remove(Item)
        End Sub 'Remove

        ' ------------------------------------------------------------------------
        ' -- Method: RemoveAt
        ' -- Removes the first occurrence of a specific object from the Collection. 
        ' ------------------------------------------------------------------------	
        'Public Sub Remove(ByVal Item As ClientDetails)
        '	MyBase.List.Remove(Item)
        'End Sub 'Remove

        ' ------------------------------------------------------------------------
        ' -- Method: Contains
        ' -- Determines whether the CollectionBase contains a specific element. 
        ' ------------------------------------------------------------------------
        Public Function Contains(ByVal Item As ClientDetails) As Boolean
            ' If value is not of type ClientDetails, this will return false.
            Return MyBase.List.Contains(Item)
        End Function 'Contains

    End Class

#End Region

End Namespace

Namespace Secura.WHMCS.Data.CollectionHelpers.ClientDetailsBase

#Region " ** Interface Definitions ** "
    Public Interface IGenericComparer
        Inherits IComparer

        'IGeneriComparer Extends IComparer to include ObjectType,
        'SortByName, And SortingOrder Properties

        Property SortObjectType() As System.Type
        Property SortByName() As String
        Property SortDirection() As Integer
    End Interface

    Public Interface ISortable
        'A new interface for the abstract implementation that
        'includes our Sort method

        Property SortObjectType() As System.Type
        Property SortByName() As String
        Property SortDirection() As GenericComparer.SorterDirection

        Sub Sort()
    End Interface
#End Region

    '-----------------------------------------
    '----- Generic Comparer Class
    '----- This Class Implements the IGenericComparer interface
    '-----------------------------------------
#Region " ** GenericComparer Class ** "
    Public NotInheritable Class GenericComparer 'Sealed class
        Implements IGenericComparer

        Public Enum SorterDirection
            Ascending = 0
            Descending = 1
        End Enum

        Private m_SortObjectType As System.Type
        Private m_SortByName As String = ""
        Private m_SortDirection As Integer = 0

        Property SortObjectType() As System.Type Implements IGenericComparer.SortObjectType
            Get
                Return m_SortObjectType
            End Get
            Set(ByVal value As System.Type)
                m_SortObjectType = value
            End Set
        End Property

        Property SortByName() As String Implements IGenericComparer.SortByName
            Get
                Return m_SortByName
            End Get
            Set(ByVal value As String)
                m_SortByName = value
            End Set
        End Property

        Property SortDirection() As Integer Implements IGenericComparer.SortDirection
            Get
                Return m_SortDirection
            End Get
            Set(ByVal value As Integer)
                m_SortDirection = value
            End Set
        End Property

        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            'Basedon the property name we have to get the property info
            Dim oPropertyInfo As PropertyInfo = SortObjectType.GetProperty(m_SortByName)

            'Nowthat we have the property Info we can get the value of each of theproperties
            'castas IComparable objects
            Dim object1 As IComparable = DirectCast(oPropertyInfo.GetValue(x, Nothing), IComparable)
            Dim object2 As IComparable = DirectCast(oPropertyInfo.GetValue(y, Nothing), IComparable)

            'Nowall we have to do is compare the properties with the CompareTo method
            'Inheritedfrom IComparable
            If SortDirection = 0 Then
                Return (object1.CompareTo(object2))
            Else
                Return (object2.CompareTo(object1))
            End If
        End Function

    End Class
#End Region

    '-----------------------------------------
    '----- Abstract Implementation Class -----
    '-----------------------------------------
#Region " ** SortableCollectionBase Class** "
    Public MustInherit Class SortableCollectionBase
        Inherits Collections.CollectionBase
        Implements ISortable

        'Thisclass must be inherited and is our new Collection Class inheritedfrom
        'CollectionBaseand implementing our ISortable interface

        Private m_SortByName As String = ""
        Private m_SortDirection As GenericComparer.SorterDirection
        Private m_SortObjectType As System.Type

        Public Property SortByName() As String Implements ISortable.SortByName
            Get
                Return m_SortByName
            End Get
            Set(ByVal value As String)
                m_SortByName = value
            End Set
        End Property

        Public Property SortDirection() As GenericComparer.SorterDirection Implements ISortable.SortDirection
            Get
                Return m_SortDirection
            End Get
            Set(ByVal value As GenericComparer.SorterDirection)
                m_SortDirection = value
            End Set
        End Property

        Public Property SortObjectType() As System.Type Implements ISortable.SortObjectType
            Get
                Return m_SortObjectType
            End Get
            Set(ByVal value As System.Type)
                m_SortObjectType = value
            End Set
        End Property

        Overridable Sub Sort() Implements ISortable.Sort
            If m_SortByName = "" Then Throw New Exception("First Set SortByName")
            If m_SortObjectType Is Nothing Then Throw New Exception("First Set theSortObjectType")

            Dim oSorter As IGenericComparer = New GenericComparer()
            oSorter.SortObjectType = m_SortObjectType
            oSorter.SortByName = m_SortByName
            oSorter.SortDirection = CInt(m_SortDirection)

            InnerList.Sort(oSorter)
        End Sub

    End Class
#End Region

End Namespace